﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php	

	include("../inc/joomlaInt_admin.php");
	include("../inc/inc_configuration.php");
	
	if ($jUser==0)
	{
		echo "Bitte zuerst einloggen!";
	}
	else
	{
	
		$q="SELECT gid FROM $tbl_users WHERE id=$jUser";
						$qe=mysql_query($q);
						$qeo=mysql_fetch_object($qe);
						
						$gid=$qeo->gid;
						
						if ($gid!=$admingroup)
						{
							echo "Du bist kein Admin!";
							break;
						}
		
		echo "<h1>Verwarnung Anlegen</h1><br>";
		
		echo '<form action="verwarnung_anlegen.php" method="post">';
		
		echo "	<table id='tabelle' width='400'>
					<tr><th></th><th></th></tr>
					<tr>
						<td>User:</td>
						<td><select name='user' Size='1'>";
		
		$lq = "SELECT id,username FROM $tbl_users";
		$lqe = mysql_query($lq);

		while($row=mysql_fetch_object($lqe))
		{
			$uid=$row->id;
			$un=$row->username;
			echo '<Option Value="',$uid,'">',$un,'</option>';
		}
			
						
		echo"				</select></td>
					</tr>
					<tr>
						<td>Grund:</td>
						<td><input name='grund' type='text' size='30' maxlength='255'></td>
					</tr>
					<tr>
						<td></td>
						<td><input type='submit' value='Anlegen' class='button anlegen'></td>
					</tr>
					<tr>
						<th></th>
						<th></th>
					</tr></table><br><br>
					";
		
		
		echo "<h1>Verwarnungen</h1>";
		
		$q="SELECT u.username, COUNT(*) AS anz,u.id FROM $tbl_verwarnungen v, $tbl_users u WHERE u.id=v.userId GROUP BY v.userId ORDER BY anz DESC";
		$qe=mysql_query($q);
		
		echo "	<table id='tabelle' width='400'>
					<tr><th>User</th><th>Anzahl</th></tr>";
		
		while ($row=mysql_fetch_object($qe))
		{
			$un = $row->username;
			$anz = $row->anz;
			$uid = $row->id;
			
			$un = "<a href='profil.php?id=$uid'>$un</a>";
			
			echo "	<tr>
						<td>$un</td>
						<td>$anz</td>
					</tr>";
		
		}
		
		echo "<tr><th></th><th></th></tr></table><br><br>";
		
		
		
		$q="SELECT u.username,u.id,v.reason,v.date AS datum, v.id AS vid FROM $tbl_verwarnungen v, $tbl_users u WHERE u.id=v.userId ORDER BY date DESC LIMIT 0,20";
		$qe=mysql_query($q);
		
		echo "	<table id='tabelle' width='600'>
					<tr>
						<th>User</th>
						<th>Grund</th>
						<th>Datum</th>
						<th>Del</th>
					</tr>";
		
		while ($row=mysql_fetch_object($qe))
		{
			$un = $row->username;
			$reason = $row->reason;
			$datum = $row->datum;
			$vid = $row->vid;
			
			$datum=date("d.m.y - H:i",$datum);
			
			echo "	<tr>
						<td>$un</td>
						<td>$reason</td>
						<td>$datum</td>
						<td><a href='verwarnung_entfernen.php?id=$vid'>DEL</a></td>
					</tr>";
		
		}
		
		echo "<tr><th></th><th></th><th></th><th></th></tr></table>";
	
	}
	
?>

</body>
</html>